package com.atguigu.guli.service.base.config;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import javax.sql.rowset.Predicate;

@EnableSwagger2
@Configuration
public class Swagger2Config {


    @Bean
    public Docket webApiConfig(){
        ApiInfo webInfo = new ApiInfoBuilder()
                .title("谷粒学院API文档-前台管理系统")
                .description("本文档描述了学院的前端微服务接口")
                .contact(new Contact("桂云飞", "http://www.baidu.com", "772538163@qq.com"))
                .version("1.0")
                .build();

        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("webApi")
                .apiInfo(webInfo)
                .select()
                .paths(Predicates.and(PathSelectors.regex("/api/.*")))
                .build()
                ;
    }

    @Bean
    public Docket adminApiConfig(){
        ApiInfo adminInfo = new ApiInfoBuilder()
                .title("谷粒学院API文档-后台管理系统")
                .description("本文档描述了学院的后端接口")
                .contact(new Contact("桂云飞", "http://www.baidu.com", "772538163@qq.com"))
                .version("1.0")
                .build();

        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("adminApi")
                .apiInfo(adminInfo)
                .select()
                .paths(Predicates.and(PathSelectors.regex("/admin/.*")))
                .build()
                ;
    }
}
